<template>
  <a-modal
    :title="title"
    :visible="visible"
    :confirm-loading="confirmLoading"
    cancel-text="关闭"
    @ok="submit"
    @cancel="closeModal"
  >
    <a-spin :spinning="confirmLoading">
      <a-form>
        <a-form-item :label-col="labelCol" :wrapper-col="wrapperCol" label="日记等级">
          <a-radio-group v-model="isGrade">
            <a-radio :value="1">
              普通日记
            </a-radio>
            <a-radio :value="2">
              小编精选
            </a-radio>
            <a-radio :value="3">
              首页推荐
            </a-radio>
          </a-radio-group>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
import ApiTree from "@/api/diary/diaryList";
import { Slime } from '@/mixins/slime';
export default {
  name: 'editMobileModal',
  data() {
    return {
      title: '设置等级',
      detailId:0,
      isGrade:0,
    };
  },
  mixins: [Slime],
  methods: {
    // 详情
    open(detailId, grade) {
      this.isGrade = grade
      this.detailId = detailId
      this.visible = true;
    },
    // 提交
    submit() {
      const that = this;
      let param = {
        id: that.detailId,
        grade: that.isGrade
      }
      that.submitUpdate(param);
    },
    // 提交 改
    submitUpdate(param) {
      const that = this;
      ApiTree.detailUpdateInfo(param)
        .then((res) => {
          if(res.code == 0){
            that.$message.success('操作成功');
          }else{
            that.$message.warning(res.message);
          }
        })
        .finally(() => {
          that.closeModal();
        });
    },
    // 弹窗-关闭
    closeModal() {
      this.visible = false;
      this.$emit('closeModal');
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
</style>